<meta charset="utf-8">
<div id="d1"></div>
<div id="d2"></div>
<div id="d3"></div>
<script>
    var d1 = document.getElementById("d1");
    var d2 = document.getElementById("d2");
    var d3 = document.getElementById("d3");
    var timer;
    
    function show(will,d1){       
        var now = new Date();
        var diff = will.getTime() - now.getTime();
        if(diff<=0){
            d1.innerHTML = "活动已经结束";
            return;
        }
        var day = Math.floor(diff/(1000*60*60*24));
        var h = Math.floor(diff/(1000*60*60)%24);
        var m = Math.floor(diff/(1000*60)%60);
        var s = Math.floor(diff/1000%60);
        var ss =  Math.floor(diff%1000);
        d1.innerHTML = "距离活动结束时间还剩"+day+"天 "+h+":"+(m<10?"0"+m:m)+":"+(s<10?"0"+s:s)+" "+ss;
    }
    function showall(){
        show(new Date(2018,0,5,9,28,59),d1);
        show(new Date(2018,0,6,24,59,59),d2);
        show(new Date(2018,0,7,24,59,59),d3);

    }
    showall();
    setInterval(showall,1);  
</script>